import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'

const routes = [
    {
        path: '/',
        redirect: '/login'
    },
    {
        path: '/welcome',
        name: 'Welcome',
        component: () => import('../components/Welcome')
    },
    {
        path: '/login',
        name: 'Login',
        component: () => import('../views/Login.vue')
    },
    {
        path: '/console',
        name: 'Console',
        component: () => import('../views/Index.vue'),
        children: [
            {
                path: 'noPrivilege',
                name: 'NoPrivilege',
                component: () => import('../components/NoPrivilege')
            },
            {
                path: 'doctor',
                name: 'Doctor',
                component: () => import('../components/Doctor.vue'),
            },

            {
                path: 'consultation',
                name: 'consultation',
                component: () => import('../components/Consultation.vue')
            },
            {
                path: 'patient',
                name: 'Patient',
                component: () => import('../components/Patient')
            },
            {
                path: 'area',
                name: 'Area',
                component: () => import('../components/Area')
            },
            {
                path: 'role',
                name: "Role",
                component: () => import('../components/Role')
            },
            {
                path: 'condition',
                name: "Condition",
                component: () => import('../components/Condition')
            },
            {
                path: 'department',
                name: "Department",
                component: () => import('../components/Department')
            },
            {
                path: 'hospital',
                name: 'Hospital',
                component: () => import('../components/Hospital')
            },
            {
                path: 'cure',
                name: 'Cure',
                component: () => import('../components/Cure')
            },
            {
                path: 'checkout',
                name: 'Checkout',
                component: () => import('../components/Checkout')
            },
            {
                path: 'visitInfo',
                name: 'VisitInfo',
                component: () => import('../components/VisitInfo')
            },
            {
                path: 'illnessInfo',
                name: 'IllnessInfo',
                component: () => import('../components/IllnessInfo')
            },
            {
                path: 'visit',
                name: 'Visit',
                component: () => import('../components/Visit')
            }
        ],
    },
    {
        path: '/404',
        name: '404',
        component: () => import('../views/404')
    },
    {
        path: '/:pathMatch(.*)',
        redirect: '/404'
    },
]

var router;
if (process.env.NODE_ENV == 'production') {
    router = createRouter({
        history: createWebHashHistory(process.env.BASE_URL),
        routes
    })
    console.log('pro')
} else {
    router = createRouter({
        history: createWebHistory(process.env.BASE_URL),
        routes
    })
    console.log('dev')
}

export default router
